<?php $__env->startSection("content"); ?>
    <body>
    <div class="x-body">
        <form class="layui-form">
            <div class="layui-form-item">
                <label for="username" class="layui-form-label">
                    <span class="x-red">*</span>用户名
                </label>
                <div class="layui-input-inline">

                </div>
                <h2 style="font-size: 24px"><?php echo e($adminUser->name); ?></h2>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"><span class="x-red">*</span>角色</label>
                <div class="layui-input-block">
                    <?php $__currentLoopData = $adminRoles; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $adminRole): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <input type="checkbox" name="role_id[<?php echo e($adminRole->id); ?>]" lay-skin="primary" title="<?php echo e($adminRole->name); ?>"  value="<?php echo e($adminRole->id); ?>" <?php if($myRoles->contains($adminRole)): ?> checked <?php endif; ?>>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="L_repass" class="layui-form-label">
                </label>
                <button  class="layui-btn" lay-filter="add" lay-submit="">
                    编辑
                </button>
            </div>
        </form>
    </div>
    <script>
        layui.use(['form','layer'], function(){
            $ = layui.jquery;
            var form = layui.form
                ,layer = layui.layer;

            //自定义验证规则
            form.verify({
                nikename: function(value){
                    if(value.length < 5){
                        return '昵称至少得5个字符啊';
                    }
                }
                ,pass: [/(.+){6,12}$/, '密码必须6到12位']
                ,repass: function(value){
                    if($('#L_pass').val()!=$('#L_repass').val()){
                        return '两次密码不一致';
                    }
                }
            });

            //监听提交
            form.on('submit(add)', function(data){
                //发异步，把数据提交给php
                // 获得frame索引
                    $.ajax({
                        url:"/admin/user/<?php echo e($adminUser->id); ?>/role",
                        type: 'post',
                        data:data.field,
                        dataType: 'json',
                        success: function (data) {
                            if(data.error ==1){
                                layer.msg(data.info, function(){
                                });
                            }else if(data.error ==0){
                                layer.alert(data.info, {icon: 6},function(){
                                    // 获得frame索引
                                    var index = parent.layer.getFrameIndex(window.name);
                                    //关闭当前frame
                                    parent.layer.close(index);

                                    parent.location.reload();
                                });
                            }else{
                                alert(data.errors)
                            }
                        },
                        fail: function (err) {
                            console.log(err)
                        }
                    })
                return false;
            });
        });
    </script>
    </body>

    <?php $__env->stopSection(); ?>
<?php echo $__env->make("admin.layout.layout", array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>